<div id="aclIndexAdd">
<a href="<?php echo $this->url(array('controller' => 'acl', 'action' => 'details', 'roleId' => $this->role->roleId), 'ot', true); ?>" class="ui-state-default ui-corner-all linkButton"><?php echo $this->translate('ot-acl-applicationAccess:back'); ?><span class="ui-icon ui-icon-triangle-1-w"></span></a>
<br /><br />
    <?php echo $this->translate('ot-acl-applicationAccess:header'); ?>
    <br /><br />

<table class="form">
	<tbody>
		<tr>
			<td><label><?php echo $this->translate('model-role-form:roleName'); ?></label></td>
			<td><?php echo $this->role->name; ?></td>
		</tr>
		<tr>
			<td><label><?php echo $this->translate('model-role-form:inheritRoleId'); ?></label></td>
			<td><?php echo ($this->role->inheritRoleId != 0) ? $this->inheritRole->name : 'None'; ?></td>
		</tr>
	</tbody>
</table>
    <form method="post" id="aclEditor" action="" class="checkRequiredFields">
        <?php if (count($this->children) != 0) : ?>
        <div class="ui-state-highlight ui-corner-all">
        	<span class="ui-icon ui-icon-alert" style="float: left; margin-right: 0.3em;"></span>
	        <?php echo $this->translate('ot-acl-applicationAccess:caution'); ?>
	        <ul>
	        <?php foreach ($this->children as $c) : ?>
	        	<li>
	            <a href="<?php echo $this->url(array('controller' => 'acl', 'action' => 'details', 'roleId' => $c['roleId']), 'ot', true); ?>"><?php echo $c['name']; ?></a> <?php echo $this->translate('ot-acl-applicationAccess:via'); ?>
	            <a href="<?php echo $this->url(array('controller' => 'acl', 'action' => 'details', 'roleId' => $c['parent']['roleId']), 'ot', true); ?>"><?php echo $c['parent']['name']; ?></a>
	            </li>
	        <?php endforeach; ?>
	        </ul>
        </div>
        <?php endif; ?>
        <div id="accessList">
            <?php foreach ($this->resources as $module => $controllers) : ?>
            <div class="aclSection">
                <table class="list">
                    <tbody>
                    <tr class="ui-widget-header">
                        <td width="300"><b><?php echo ucwords($module); ?></b></td>
                        <td width="120"><?php echo $this->translate('ot-acl-form:currently'); ?></td>
                        <td width="180"><?php echo $this->translate('ot-acl-form:grantRevoke'); ?></td>
                    </tr>
                    <?php foreach ($controllers as $controller => $actions) : ?>
                    <tr class="controller">
                        <td title="<?php echo $actions['description']; ?>" class="td1 description">
                        <?php echo ucwords($controller); ?>
                        </td>
                        <td class="<?php if (!empty($actions['all']['access'])) { echo 'access'; } else { if (!empty($actions['someaccess'])) { echo 'someAccess'; } else { echo 'noAccess'; }} ?>">
                        <?php if (!empty($actions['all']['access'])) : ?>
                            <?php echo $this->translate('ot-acl-form:allAccess'); ?>
                        <?php else: ?>
                            <?php if (isset($actions['someaccess'])) : ?>
                            <?php echo $this->translate('ot-acl-form:someAccess'); ?>
                            <?php else: ?>
                            <?php echo $this->translate('ot-acl-form:noAccess'); ?>
                            <?php endif; ?>
                        <?php endif; ?>
                        </td>
                        <td>
                        <select size="1" class="allAccess" name="<?php echo $module . '[' . $controller . '][all]'; ?>" id="<?php echo $module . '_' . $controller; ?>">
                            <option value="<?php if (!empty($actions['all']['access'])) { echo 'allow'; } else { if (!empty($actions['someaccess'])) { echo 'some'; } else { echo 'deny'; }} ?>"><?php echo $this->translate('ot-acl-form:noChange'); ?></option>
                        <?php if (empty($actions['all']['access'])) : ?>
                            <option value="allow"><?php echo $this->translate('ot-acl-form:grantAllAccess'); ?></option>
                        <?php endif; ?>
                        <?php if (empty($actions['someaccess']) || !empty($actions['all']['access'])) : ?>
                            <option value="some"><?php echo (empty($actions['all']['access'])) ? $this->translate('ot-acl-form:grant') : $this->translate('ot-acl-form:revoke'); ?> <?php echo $this->translate('ot-acl-form:someAccess'); ?></option>
                        <?php endif; ?>
                        <?php if (!empty($actions['all']['access']) || !empty($actions['someaccess'])) : ?>
                            <option value="deny"><?php echo $this->translate('ot-acl-form:revokeAllAccess'); ?></option>
                        <?php endif; ?>
                        </select>
                        </td>
                    </tr>
                    <?php if (isset($actions['part'])): ?>
                        <?php foreach ($actions['part'] as $action => $access) : ?>
                    <tr class="action <?php echo $module . '_' . $controller; ?>" style="display: <?php echo (empty($actions['someaccess']) || !empty($actions['all']['access'])) ? 'none' : ''; ?>;">
                        <td class="td1 description" title="<?php echo $access['description']; ?>">
                        <?php echo ucwords($action); ?>
                        </td>
                        <td class="<?php echo (!empty($access['access'])) ? 'access' : 'noAccess'; ?>"><?php echo (!empty($access['access'])) ? $this->translate('ot-acl-form:hasAccess') : $this->translate('ot-acl-form:noAccess'); ?></td>
                        <td class="td3"><input type="checkbox" class="<?php echo $module . '_' . $controller; ?>_action" value="<?php echo (!empty($access['access'])) ? 'deny' : 'allow'; ?>" name="<?php echo $module . '[' . $controller . '][part][' . $action . ']'; ?>" id="<?php echo $module . '_' . $controller . '_part_' . $action; ?>" /> <?php echo (!empty($access['access'])) ? $this->translate('ot-acl-form:revokeAccess') : $this->translate('ot-acl-form:grantAccess'); ?></td>
                    </tr>
                        <?php endforeach; ?>
                    <?php endif; ?>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            <?php endforeach; ?>
			<input type="submit" value="<?php echo $this->translate('model-role-form:submit'); ?>" /> 
			<button type="button" id="cancel"><?php echo $this->translate('form-button-cancel'); ?></button>
        </div>
        
    </form>
</div>